﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="With_DefaultValueConverter.cs" company="JDML Consulting Ltd.">
//   Copyright 2011 Photon Project - http://photon.codeplex.com
// </copyright>
// <summary>
//   Defines the DefaultValueConverterTests type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Photon
{
    using System;
    using System.Linq;
    using System.Reflection;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Windows;

    // ReSharper disable RedundantTypeArgumentsOfMethod
    [TestClass]
    public class With_DefaultValueConverter
    {
        private class ConvertAssert
        {
            #region Fields

            private readonly object[] _values;

            #endregion

            public ConvertAssert(params object[] values)
            {
                _values = (object[])values.Clone();
            }

            public void AssertConvertsTo<T>(params T[] expected)
            {
                Assert.AreEqual(_values.Length, expected.Length, "Expected values length does not match values length.");
                for (var i = 0; i < _values.Length; i++)
                {
                    ConvertsTo(_values[i], expected[i]);
                }
            }

            public void ConvertsTo<T>(T expected)
            {
                foreach (var value in _values)
                {
                    ConvertsTo(value, expected);
                }
            }

            private static void ConvertsTo<T>(object value, T expected)
            {
                object convertedValue;
                Assert.IsTrue(DefaultValueConverter.Instance.TryChangeType(value, typeof(T), out convertedValue),
                    "Expected conversion to succeed when converting from {0} ({1}) to type {2}.", value, value != null ? value.GetType() : null, typeof(T));
                Assert.AreEqual(expected, convertedValue, "Unexpected conversion result when converting from {0} ({1}) to type {2}, expected {3}, actual {4}.",
                    value, value != null ? value.GetType() : null, typeof(T), expected, convertedValue);
            }

            public void AssertNotConvertsTo<T>()
            {
                foreach (var value in _values)
                {
                    object convertedValue;
                    Assert.IsFalse(DefaultValueConverter.Instance.TryChangeType(value, typeof(T), out convertedValue),
                        "Expected conversion to fail when converting from {0} ({1}) to type {2}, converted value = {3}.", 
                        value, value.GetType(), typeof(T), convertedValue);
                }
            }
        }

        private static ConvertAssert WithSourceValues<T>(params T[] values)
        {
            return new ConvertAssert(values.Cast<object>().ToArray());
        }

        #region Object Tests

        [TestMethod]
        public void When_convert_type_to_same_type()
        {
            var obj = new object();
            WithSourceValues(obj)
                .AssertConvertsTo<object>(obj);
        }

        [TestMethod]
        public void When_convert_type_to_assignable_as_type()
        {
            WithSourceValues(1)
                .AssertConvertsTo<IConvertible>(1);
        }

        #endregion

        #region Enum Tests

        [TestMethod]
        public void When_convert_int_to_enum()
        {
            WithSourceValues((int)BindingFlags.Public)
                .AssertConvertsTo<BindingFlags>(BindingFlags.Public);
        }

        [TestMethod]
        public void When_convert_string_to_enum()
        {
            WithSourceValues("Public")
                .AssertConvertsTo<BindingFlags>(BindingFlags.Public);
            WithSourceValues("Oops")
                .AssertNotConvertsTo<BindingFlags>();
        }

        #endregion

        #region SByte Tests

        [TestMethod]
        public void When_convert_byte_to_sbyte()
        {
            WithSourceValues(Byte.MinValue, (byte)SByte.MaxValue)
                .AssertConvertsTo<sbyte>(0, SByte.MaxValue);
            WithSourceValues<byte>((byte)SByte.MaxValue + 1, Byte.MaxValue)
                .AssertNotConvertsTo<sbyte>();
        }

        [TestMethod]
        public void When_convert_sbyte_to_sbyte()
        {
            WithSourceValues<sbyte>(SByte.MinValue, SByte.MaxValue, 0)
                .AssertConvertsTo<sbyte>(SByte.MinValue, SByte.MaxValue, 0);
        }

        [TestMethod]
        public void When_convert_uint16_to_sbyte()
        {
            WithSourceValues(UInt16.MinValue, (ushort)SByte.MaxValue)
                .AssertConvertsTo<sbyte>(0, SByte.MaxValue);
            WithSourceValues<ushort>((ushort)SByte.MaxValue + 1, UInt16.MaxValue)
                .AssertNotConvertsTo<sbyte>();
        }

        [TestMethod]
        public void When_convert_int16_to_sbyte()
        {
            WithSourceValues<short>(SByte.MinValue, SByte.MaxValue, 0)
                .AssertConvertsTo<sbyte>(SByte.MinValue, SByte.MaxValue, 0);
            WithSourceValues<short>(SByte.MinValue - 1, SByte.MaxValue + 1, Int16.MinValue, Int16.MaxValue)
                .AssertNotConvertsTo<sbyte>();
        }

        [TestMethod]
        public void When_convert_uint32_to_sbyte()
        {
            WithSourceValues(UInt32.MinValue, (uint)SByte.MaxValue)
                .AssertConvertsTo<sbyte>(0, SByte.MaxValue);
            WithSourceValues((uint)SByte.MaxValue + 1, UInt32.MaxValue)
                .AssertNotConvertsTo<sbyte>();
        }

        [TestMethod]
        public void When_convert_int32_to_sbyte()
        {
            WithSourceValues(SByte.MinValue, SByte.MaxValue, 0)
                .AssertConvertsTo<sbyte>(SByte.MinValue, SByte.MaxValue, 0);
            WithSourceValues(SByte.MinValue - 1, SByte.MaxValue + 1, Int32.MinValue, Int32.MaxValue)
                .AssertNotConvertsTo<sbyte>();
        }

        [TestMethod]
        public void When_convert_uint64_to_sbyte()
        {
            WithSourceValues(UInt64.MinValue, (ulong)SByte.MaxValue)
                .AssertConvertsTo<sbyte>(0, SByte.MaxValue);
            WithSourceValues((ulong)SByte.MaxValue + 1UL, UInt64.MaxValue)
                .AssertNotConvertsTo<sbyte>();
        }

        [TestMethod]
        public void When_convert_int64_to_sbyte()
        {
            WithSourceValues<long>(SByte.MinValue, SByte.MaxValue, 0)
                .AssertConvertsTo<sbyte>(SByte.MinValue, SByte.MaxValue, 0);
            WithSourceValues(SByte.MinValue - 1L, SByte.MaxValue + 1L, Int64.MinValue, Int64.MaxValue)
                .AssertNotConvertsTo<sbyte>();
        }

        [TestMethod]
        public void When_convert_single_to_sbyte()
        {
            WithSourceValues(SByte.MinValue, SByte.MaxValue, 0.0f, SByte.MaxValue + 0.1f, SByte.MinValue - 0.1f)
                .AssertConvertsTo<sbyte>(SByte.MinValue, SByte.MaxValue, 0, SByte.MaxValue, SByte.MinValue);
            WithSourceValues((Single)SByte.MinValue - 1, (Single)SByte.MaxValue + 1)
                .AssertNotConvertsTo<sbyte>();
        }

        [TestMethod]
        public void When_convert_double_to_sbyte()
        {
            WithSourceValues(SByte.MinValue, SByte.MaxValue, 0.0, SByte.MinValue - 0.1, SByte.MaxValue + 0.1)
                .AssertConvertsTo<sbyte>(SByte.MinValue, SByte.MaxValue, 0, SByte.MinValue, SByte.MaxValue);
            WithSourceValues(SByte.MaxValue + 1.0, SByte.MinValue - 1.0, Double.MinValue, Double.MaxValue)
                .AssertNotConvertsTo<sbyte>();
        }

        [TestMethod]
        public void When_convert_decimal_to_sbyte()
        {
            WithSourceValues(SByte.MinValue, SByte.MaxValue, 0.0M, SByte.MinValue - 0.1M, SByte.MaxValue + 0.1M)
                .AssertConvertsTo<sbyte>(SByte.MinValue, SByte.MaxValue, 0, SByte.MinValue, SByte.MaxValue);
            WithSourceValues(SByte.MaxValue + 1.0M, SByte.MinValue - 1.0M, Decimal.MinValue, Decimal.MaxValue)
                .AssertNotConvertsTo<sbyte>();
        }

        [TestMethod]
        public void When_convert_string_to_sbyte()
        {
            WithSourceValues("1")
                .AssertConvertsTo<sbyte>(1);
            WithSourceValues("-1")
                .AssertConvertsTo<sbyte>(-1);
        }

        [TestMethod]
        public void When_convert_data_time_to_sbyte()
        {
            WithSourceValues(DateTime.Now)
                .AssertNotConvertsTo<sbyte>();
        }

        #endregion

        #region Int16 Tests

        [TestMethod]
        public void When_convert_byte_to_int16()
        {
            WithSourceValues<byte>(Byte.MinValue, Byte.MaxValue, 127)
                .AssertConvertsTo<short>(0, 255, 127);
        }

        [TestMethod]
        public void When_convert_sbyte_to_int16()
        {
            WithSourceValues<sbyte>(SByte.MinValue, SByte.MaxValue, 0)
                .AssertConvertsTo<short>(-128, 127, 0);
        }

        [TestMethod]
        public void When_convert_uint16_to_int16()
        {
            WithSourceValues(UInt16.MinValue, (ushort)Int16.MaxValue)
                .AssertConvertsTo<short>(0, Int16.MaxValue);
            WithSourceValues<ushort>((ushort)Int16.MaxValue + 1, UInt16.MaxValue)
                .AssertNotConvertsTo<short>();
        }

        [TestMethod]
        public void When_convert_int16_to_int16()
        {
            WithSourceValues<short>(Int16.MinValue, Int16.MaxValue, 0)
                .AssertConvertsTo<short>(Int16.MinValue, Int16.MaxValue, 0);
        }

        [TestMethod]
        public void When_convert_uint32_to_int16()
        {
            WithSourceValues(UInt32.MinValue, (uint)Int16.MaxValue)
                .AssertConvertsTo<short>(0, Int16.MaxValue);
            WithSourceValues((uint)Int16.MaxValue + 1, UInt32.MaxValue)
                .AssertNotConvertsTo<short>();
        }

        [TestMethod]
        public void When_convert_int32_to_int16()
        {
            WithSourceValues(Int16.MinValue, Int16.MaxValue, 0)
                .AssertConvertsTo<short>(Int16.MinValue, Int16.MaxValue, 0);
            WithSourceValues(Int16.MinValue - 1, Int16.MaxValue + 1, Int32.MinValue, Int32.MaxValue)
                .AssertNotConvertsTo<short>();
        }

        [TestMethod]
        public void When_convert_uint64_to_int16()
        {
            WithSourceValues(UInt64.MinValue, (ulong)Int16.MaxValue)
                .AssertConvertsTo<short>(0, Int16.MaxValue);
            WithSourceValues((ulong)Int16.MaxValue + 1UL, UInt64.MaxValue)
                .AssertNotConvertsTo<short>();
        }

        [TestMethod]
        public void When_convert_int64_to_int16()
        {
            WithSourceValues<long>(Int16.MinValue, Int16.MaxValue, 0)
                .AssertConvertsTo<short>(Int16.MinValue, Int16.MaxValue, 0);
            WithSourceValues(Int16.MinValue - 1L, Int16.MaxValue + 1L, Int64.MinValue, Int64.MaxValue)
                .AssertNotConvertsTo<short>();
        }

        [TestMethod]
        public void When_convert_single_to_int16()
        {
            WithSourceValues(Int16.MinValue, Int16.MaxValue, 0.0f, Int16.MaxValue + 0.1f, Int16.MinValue - 0.1f)
                .AssertConvertsTo<short>(Int16.MinValue, Int16.MaxValue, 0, Int16.MaxValue, Int16.MinValue);
            WithSourceValues((float)Int16.MinValue - 1, (float)Int16.MaxValue + 1)
                .AssertNotConvertsTo<short>();
        }

        [TestMethod]
        public void When_convert_double_to_int16()
        {
            WithSourceValues(Int16.MinValue, Int16.MaxValue, 0.0, Int16.MinValue - 0.1, Int16.MaxValue + 0.1)
                .AssertConvertsTo<short>(Int16.MinValue, Int16.MaxValue, 0, Int16.MinValue, Int16.MaxValue);
            WithSourceValues(Int16.MaxValue + 1.0, Int16.MinValue - 1.0, Double.MinValue, Double.MaxValue)
                .AssertNotConvertsTo<short>();
        }

        [TestMethod]
        public void When_convert_decimal_to_int16()
        {
            WithSourceValues(Int16.MinValue, Int16.MaxValue, 0.0M, Int16.MinValue - 0.1M, Int16.MaxValue + 0.1M)
                .AssertConvertsTo<short>(Int16.MinValue, Int16.MaxValue, 0, Int16.MinValue, Int16.MaxValue);
            WithSourceValues(Int16.MaxValue + 1.0M, Int16.MinValue - 1.0M, Decimal.MinValue, Decimal.MaxValue)
                .AssertNotConvertsTo<short>();
        }

        [TestMethod]
        public void When_convert_string_to_int16()
        {
            WithSourceValues("1")
                .AssertConvertsTo<short>(1);
        }

        [TestMethod]
        public void When_convert_data_time_to_int16()
        {
            WithSourceValues(DateTime.Now)
                .AssertNotConvertsTo<short>();
        }

        #endregion

        #region Int32 Tests

        [TestMethod]
        public void When_convert_byte_to_int32()
        {
            WithSourceValues<byte>(Byte.MinValue, Byte.MaxValue, 127)
                .AssertConvertsTo<int>(0, 255, 127);
        }

        [TestMethod]
        public void When_convert_sbyte_to_int32()
        {
            WithSourceValues<sbyte>(SByte.MinValue, SByte.MaxValue, 0)
                .AssertConvertsTo<int>(-128, 127, 0);
        }

        [TestMethod]
        public void When_convert_uint16_to_int32()
        {
            WithSourceValues<ushort>(UInt16.MinValue, UInt16.MaxValue, 32767)
                .AssertConvertsTo<int>(0, 65535, 32767);
        }

        [TestMethod]
        public void When_convert_int16_to_int32()
        {
            WithSourceValues<short>(Int16.MinValue, Int16.MaxValue, 0)
                .AssertConvertsTo<int>(-32768, 32767, 0);
        }

        [TestMethod]
        public void When_convert_uint32_to_int32()
        {
            WithSourceValues<uint>(UInt32.MinValue, Int32.MaxValue)
                .AssertConvertsTo<int>(0, Int32.MaxValue);
            WithSourceValues(Int32.MaxValue + 1U, UInt32.MaxValue)
                .AssertNotConvertsTo<int>();
        }

        [TestMethod]
        public void When_convert_int32_to_int32()
        {
            WithSourceValues(Int32.MinValue, Int32.MaxValue, 0)
                .AssertConvertsTo<int>(Int32.MinValue, Int32.MaxValue, 0);
        }

        [TestMethod]
        public void When_convert_uint64_to_int32()
        {
            WithSourceValues<ulong>(UInt64.MinValue, Int32.MaxValue)
                .AssertConvertsTo<int>(0, Int32.MaxValue);
            WithSourceValues(Int32.MaxValue + 1UL, UInt64.MaxValue)
                .AssertNotConvertsTo<int>();
        }

        [TestMethod]
        public void When_convert_int64_to_int32()
        {
            WithSourceValues<long>(Int32.MinValue, Int32.MaxValue, 0)
                .AssertConvertsTo<int>(Int32.MinValue, Int32.MaxValue, 0);
            WithSourceValues(Int32.MinValue - 1L, Int32.MaxValue + 1L, Int64.MinValue, Int64.MaxValue)
                .AssertNotConvertsTo<int>();
        }

        [TestMethod]
        public void When_convert_single_to_int32()
        {
            WithSourceValues(Int32.MinValue, Int32.MaxValue - 1023.0f, 0.0f)
                .AssertConvertsTo<int>(Int32.MinValue, Int32.MaxValue - 1023, 0);
            WithSourceValues(Single.MinValue, Single.MaxValue)
                .AssertNotConvertsTo<int>();
        }

        [TestMethod]
        public void When_convert_double_to_int32()
        {
            WithSourceValues(Int32.MinValue, Int32.MaxValue - 1023.0, 0.0)
                .AssertConvertsTo<int>(Int32.MinValue, Int32.MaxValue - 1023, 0);
            WithSourceValues(Int32.MaxValue + 1.0, Int32.MinValue - 1022.0, Double.MinValue, Double.MaxValue)
                .AssertNotConvertsTo<int>();
        }

        [TestMethod]
        public void When_convert_decimal_to_int32()
        {
            WithSourceValues(Int32.MinValue, Int32.MaxValue, 0.0M)
                .AssertConvertsTo<int>(Int32.MinValue, Int32.MaxValue, 0);
            WithSourceValues(Int32.MaxValue + 1.0M, Int32.MinValue - 1.0M, Decimal.MinValue, Decimal.MaxValue)
                .AssertNotConvertsTo<int>();
        }

        [TestMethod]
        public void When_convert_string_to_int32()
        {
            WithSourceValues("1")
                .AssertConvertsTo<int>(1);
        }

        [TestMethod]
        public void When_convert_data_time_to_int32()
        {
            WithSourceValues(DateTime.Now)
                .AssertNotConvertsTo<int>();
        }

        #endregion

        #region Int64 Tests

        [TestMethod]
        public void When_convert_byte_to_int64()
        {
            WithSourceValues<byte>(Byte.MinValue, Byte.MaxValue, 127)
                .AssertConvertsTo<long>(Byte.MinValue, Byte.MaxValue, 127);
        }

        [TestMethod]
        public void When_convert_sbyte_to_int64()
        {
            WithSourceValues<sbyte>(SByte.MinValue, SByte.MaxValue, 0)
                .AssertConvertsTo<long>(SByte.MinValue, SByte.MaxValue, 0);
        }

        [TestMethod]
        public void When_convert_uint16_to_int64()
        {
            WithSourceValues<ushort>(UInt16.MinValue, UInt16.MaxValue, 32767)
                .AssertConvertsTo<long>(UInt16.MinValue, UInt16.MaxValue, 32767);
        }

        [TestMethod]
        public void When_convert_int16_to_int64()
        {
            WithSourceValues<short>(Int16.MinValue, Int16.MaxValue, 0)
                .AssertConvertsTo<long>(Int16.MinValue, Int16.MaxValue, 0);
        }

        [TestMethod]
        public void When_convert_uint32_to_int64()
        {
            WithSourceValues<uint>(UInt32.MinValue, Int32.MaxValue)
                .AssertConvertsTo<long>(UInt32.MinValue, Int32.MaxValue);
        }

        [TestMethod]
        public void When_convert_int32_to_int64()
        {
            WithSourceValues(Int32.MinValue, Int32.MaxValue, 0)
                .AssertConvertsTo<long>(Int32.MinValue, Int32.MaxValue, 0);
        }

        [TestMethod]
        public void When_convert_uint64_to_int64()
        {
            WithSourceValues<ulong>(UInt64.MinValue, Int64.MaxValue)
                .AssertConvertsTo<long>(0, Int64.MaxValue);
            WithSourceValues(Int64.MaxValue + 1UL, UInt64.MaxValue)
                .AssertNotConvertsTo<long>();
        }

        [TestMethod]
        public void When_convert_int64_to_int64()
        {
            WithSourceValues(Int64.MinValue, Int64.MaxValue, 0)
                .AssertConvertsTo<long>(Int64.MinValue, Int64.MaxValue, 0);
        }

        [TestMethod]
        public void When_convert_single_to_int64()
        {
            WithSourceValues(Int64.MinValue, Int32.MaxValue - 1023.0f, 0.0f)
                .AssertConvertsTo<long>(Int64.MinValue, Int32.MaxValue - 1023, 0);
            WithSourceValues(Single.MinValue, Single.MaxValue)
                .AssertNotConvertsTo<long>();
        }

        [TestMethod]
        public void When_convert_double_to_int64()
        {
            WithSourceValues(Int64.MinValue, Int32.MaxValue - 1023.0, 0.0)
                .AssertConvertsTo<long>(Int64.MinValue, Int32.MaxValue - 1023, 0);
            WithSourceValues(Double.MinValue, Double.MaxValue)
                .AssertNotConvertsTo<long>();
        }

        [TestMethod]
        public void When_convert_decimal_to_int64()
        {
            WithSourceValues(Int64.MinValue, Int64.MaxValue, 0.0M)
                .AssertConvertsTo<long>(Int64.MinValue, Int64.MaxValue, 0);
            WithSourceValues(Int64.MaxValue + 1.0M, Int64.MinValue - 1.0M, Decimal.MinValue, Decimal.MaxValue)
                .AssertNotConvertsTo<long>();
        }

        [TestMethod]
        public void When_convert_string_to_int64()
        {
            WithSourceValues("1")
                .AssertConvertsTo<long>(1);
        }

        [TestMethod]
        public void When_convert_data_time_to_int64()
        {
            WithSourceValues(DateTime.Now)
                .AssertNotConvertsTo<long>();
        }

        #endregion

        #region UInt32 Tests

        [TestMethod]
        public void When_convert_byte_to_uint32()
        {
            WithSourceValues<byte>(Byte.MinValue, Byte.MaxValue, 127)
                .AssertConvertsTo<uint>(0, 255, 127);
        }

        [TestMethod]
        public void When_convert_sbyte_to_uint32()
        {
            WithSourceValues<sbyte>(0, SByte.MaxValue)
                .AssertConvertsTo<uint>(0, 127);
            WithSourceValues<sbyte>(-1)
                .AssertNotConvertsTo<uint>();
        }

        [TestMethod]
        public void When_convert_uint16_to_uint32()
        {
            WithSourceValues<ushort>(UInt16.MinValue, UInt16.MaxValue, 32767)
                .AssertConvertsTo<uint>(0, UInt16.MaxValue, 32767);
        }

        [TestMethod]
        public void When_convert_int16_to_uint32()
        {
            WithSourceValues<short>(0, Int16.MaxValue)
                .AssertConvertsTo<uint>(0, (uint)Int16.MaxValue);
            WithSourceValues<short>(-1)
                .AssertNotConvertsTo<uint>();
        }

        [TestMethod]
        public void When_convert_uint32_to_uint32()
        {
            WithSourceValues(UInt32.MinValue, UInt32.MaxValue)
                .AssertConvertsTo(UInt32.MinValue, UInt32.MaxValue);
        }

        [TestMethod]
        public void When_convert_int32_to_uint32()
        {
            WithSourceValues(0, Int32.MaxValue)
                .AssertConvertsTo<uint>(0, Int32.MaxValue);
            WithSourceValues(-1)
                .AssertNotConvertsTo<uint>();
        }

        [TestMethod]
        public void When_convert_uint64_to_uint32()
        {
            WithSourceValues<ulong>(UInt32.MinValue, UInt32.MaxValue)
                .AssertConvertsTo<uint>(UInt32.MinValue, UInt32.MaxValue);
            WithSourceValues(UInt32.MaxValue + 1UL, UInt64.MaxValue)
                .AssertNotConvertsTo<uint>();
        }

        [TestMethod]
        public void When_convert_int64_to_uint32()
        {
            WithSourceValues<long>(0, UInt32.MaxValue)
                .AssertConvertsTo<uint>(0, UInt32.MaxValue);
            WithSourceValues(-1, UInt32.MaxValue + 1L, Int64.MaxValue)
                .AssertNotConvertsTo<uint>();
        }

        [TestMethod]
        public void When_convert_single_to_uint32()
        {
            WithSourceValues(UInt32.MinValue, UInt32.MaxValue - 1023.0f)
                .AssertConvertsTo<uint>(UInt32.MinValue, UInt32.MaxValue - 1023);
            WithSourceValues(Single.MinValue, Single.MaxValue)
                .AssertNotConvertsTo<uint>();
        }

        [TestMethod]
        public void When_convert_double_to_uint32()
        {
            WithSourceValues(UInt32.MinValue, UInt32.MaxValue - 1023.0)
                .AssertConvertsTo<uint>(UInt32.MinValue, UInt32.MaxValue - 1023);
            WithSourceValues(UInt32.MaxValue + 1.0, Double.MinValue, Double.MaxValue)
                .AssertNotConvertsTo<int>();
        }

        [TestMethod]
        public void When_convert_decimal_to_uint32()
        {
            WithSourceValues(UInt32.MinValue, UInt32.MaxValue, 0.0M)
                .AssertConvertsTo<uint>(UInt32.MinValue, UInt32.MaxValue, 0);
            WithSourceValues(UInt32.MaxValue + 1.0M, UInt32.MinValue - 1.0M, Decimal.MinValue, Decimal.MaxValue)
                .AssertNotConvertsTo<uint>();
        }

        [TestMethod]
        public void When_convert_string_to_uint32()
        {
            WithSourceValues("1")
                .AssertConvertsTo<uint>(1);
        }
        [TestMethod]
        public void When_convert_data_time_to_uint32()
        {
            WithSourceValues(DateTime.Now)
                .AssertNotConvertsTo<uint>();
        }
        #endregion

        [TestMethod]
        public void When_converting_string_to_nullable_int32()
        {
            WithSourceValues<string>("1", null)
                .AssertConvertsTo<int?>(1, null);
        }
    }

    // ReSharper restore RedundantTypeArgumentsOfMethod
}
